<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>订单号：</label>
                                <input type="text" name="ns"/>
                            </li>
                            <li>
                                <label>商品的名称：</label>
                                <input type="text" name="productTitle"/>
                            </li>
                            <li>
                                <label>购买人昵称：</label>
                                <input type="text" name="buyerNickname"/>
                            </li>
                            <li>
                                <label>支付状态：</label>
                                <select name="payStatus">
                                    <option value="">所有</option>
                                    <option value="1">未付款</option>
                                    <option value="2">线下付款</option>
                                    <option value="3">微信</option>
                                    <option value="9">已经付款</option>
                                </select>
                            </li>
                            <li class="col-sm-3">
                                <label>支付时间：</label>
                                <div class="input-daterange input-group">
                                    <input type="text" class="input-sm form-control" name="params[startPayTime]" id="laydate-startPayTime" placeholder="年-月-日" autocomplete="off"/>
                                    <span class="input-group-addon">到</span>
                                    <input type="text" class="input-sm form-control" name="params[endPayTime]" id="laydate-endPayTime" placeholder="年-月-日" autocomplete="off"/>
                                </div>
                            </li>

                            <li class="col-sm-3">
                                <label>下单时间：</label>
                                <div class="input-daterange input-group">
                                    <input type="text" class="input-sm form-control" name="params[startTime]" id="laydate-startTime" placeholder="年-月-日" autocomplete="off"/>
                                    <span class="input-group-addon">到</span>
                                    <input type="text" class="input-sm form-control" name="params[endTime]" id="laydate-endTime" placeholder="年-月-日" autocomplete="off"/>
                                </div>
                            </li>
                            <li>
                                <label>第三方订单号：</label>
                                <input type="text" name="paymentOuterId"/>
                            </li>
                            <li>
                                <label>收货人手机号：</label>
                                <input type="text" name="deliveryAddrMobile"/>
                            </li>
                            <li>
                                <label>交易状态：</label>
                                <select name="tradeStatus">
                                    <option value="">所有</option>
                                    <option value="1">交易中</option>
                                    <option value="2">交易完成</option>
                                    <option value="3">取消交易</option>
                                    <option value="4">申请退款</option>
                                    <option value="5">拒绝退款</option>
                                    <option value="6">退款中</option>
                                    <option value="7">退款完成</option>
                                    <option value="9">交易结束</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="shop:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="shop:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var removeFlag = [[${@permission.hasPermi('shop:order:remove')}]];
        var prefix = ctx + "shop/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '订单id',
                    visible: false
                },
                {
                    field: 'ns',
                    title: '订单号',
                    formatter: function(value, row, index) {
                        return value + "<a href='javascript:void(0)' onclick='view("+row.id+")'>详细</a>";
                    }
                },
                {
                    field: 'productType',
                    title: '商品的类型'
                },
                {
                    field: 'productTitle',
                    title: '商品的名称'
                },
                {
                    field: 'productSummary',
                    title: '商品描述'
                },
                {
                    field: 'buyerNickname',
                    title: '购买人昵称'
                },
                {
                    field: 'buyerMsg',
                    title: '用户留言'
                },
                {
                    field: 'orderTotalAmount',
                    title: '订单总金额'
                },
                {
                    field: 'orderRealAmount',
                    title: '订单的真实金额'
                },
                {
                    field: 'couponCode',
                    title: '优惠码'
                },
                {
                    field: 'couponAmount',
                    title: '优惠金额'
                },
                {
                    field: 'payStatus',
                    title: '支付状态',
                    formatter: function(value, row, index) {
                        if(1==value){
                            return "未付款";
                        } else if(2==value){
                            return "线下付款";
                        } else if(3==value){
                            return "微信";
                        } else if(9==value){
                            return "已经付款";
                        }
                    }
                },
                {
                    field: 'paySuccessAmount',
                    title: '支付成功的金额'
                },
                {
                    field: 'paySuccessTime',
                    title: '支付时间'
                },
                {
                    field: 'paySuccessProof',
                    title: '支付证明'
                },
                {
                    field: 'paySuccessRemarks',
                    title: '支付备注'
                },
                {
                    field: 'paymentOuterId',
                    title: '第三方订单号'
                },
                {
                    field: 'deliveryId',
                    title: '发货情况'
                },
                {
                    field: 'deliveryType',
                    title: '发货类型',
                    formatter: function(value, row, index) {
                        if (1 == value) {
                            return "邮寄";
                        } else if (2 == value) {
                            return "自取";
                        } else if (3 == value) {
                            return "配送";
                        }
                    }
                },
                {
                    field: 'deliveryStatus',
                    title: '发货状态',
                    formatter: function(value, row, index) {
                        if (1 == value) {
                            return "未发货";
                        } else if (2 == value) {
                            return "配送中";
                        } else if (3 == value) {
                            return "已完成";
                        }
                    }
                },
                {
                    field: 'deliveryAddrUsername',
                    title: '收货人地址'
                },
                {
                    field: 'deliveryAddrMobile',
                    title: '收货人手机号'
                },
                {
                    field: 'deliveryAddrProvince',
                    title: '省'
                },
                {
                    field: 'deliveryAddrCity',
                    title: '城市'
                },
                {
                    field: 'deliveryAddrDistrict',
                    title: '区'
                },
                {
                    field: 'deliveryAddrDetail',
                    title: '详细地址'
                },
                {
                    field: 'deliveryAddrZipcode',
                    title: '邮政编码'
                },
                {
                    field: 'remark',
                    title: '管理员后台备注'
                },
                {
                    field: 'tradeStatus',
                    title: '交易状态',
                    formatter: function(value, row, index) {
                        if(1==value){
                            return "交易中";
                        } else if(2==value){
                            return "交易完成";
                        } else if (3==value){
                            return "取消交易"
                        } else if (4==value){
                            return "申请退款"
                        } else if (5==value){
                            return "拒绝退款"
                        } else if (6==value){
                            return "退款中"
                        } else if (7==value){
                            return "退款完成"
                        } else if (9==value){
                            return "交易结束"
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="view(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);

            initLaydateDate();
        });

        function view(id) {
            $.modal.open("查看订单", prefix +"/view/"+ id);
        }

        function initLaydateDate() {
            layui.use('laydate', function () {
                var laydate = layui.laydate;

                var startDate = laydate.render({
                    elem: '#laydate-startTime',
                    max: $('#laydate-endTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function (value, date) {
                        // 结束时间大于开始时间
                        if (value !== '') {
                            endDate.config.min.year = date.year;
                            endDate.config.min.month = date.month - 1;
                            endDate.config.min.date = date.date;
                        } else {
                            endDate.config.min.year = '';
                            endDate.config.min.month = '';
                            endDate.config.min.date = '';
                        }
                    }
                });

                var endDate = laydate.render({
                    elem: '#laydate-endTime',
                    min: $('#laydate-startTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function (value, date) {
                        // 开始时间小于结束时间
                        if (value !== '') {
                            startDate.config.max.year = date.year;
                            startDate.config.max.month = date.month - 1;
                            startDate.config.max.date = date.date;
                        } else {
                            startDate.config.max.year = '';
                            startDate.config.max.month = '';
                            startDate.config.max.date = '';
                        }
                    }
                });


                var startPayTime = laydate.render({
                    elem: '#laydate-startPayTime',
                    max: $('#laydate-endPayTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function (value, date) {
                        // 结束时间大于开始时间
                        if (value !== '') {
                            endPayTime.config.min.year = date.year;
                            endPayTime.config.min.month = date.month - 1;
                            endPayTime.config.min.date = date.date;
                        } else {
                            endPayTime.config.min.year = '';
                            endPayTime.config.min.month = '';
                            endPayTime.config.min.date = '';
                        }
                    }
                });

                var endPayTime = laydate.render({
                    elem: '#laydate-endPayTime',
                    min: $('#laydate-startPayTime').val(),
                    theme: 'molv',
                    trigger: 'click',
                    done: function (value, date) {
                        // 开始时间小于结束时间
                        if (value !== '') {
                            startPayTime.config.max.year = date.year;
                            startPayTime.config.max.month = date.month - 1;
                            startPayTime.config.max.date = date.date;
                        } else {
                            startPayTime.config.max.year = '';
                            startPayTime.config.max.month = '';
                            startPayTime.config.max.date = '';
                        }
                    }
                });
            });
        }
    </script>
</body>
</html>